package net.arvin.view;

import net.arvin.mobilebanksystem.R;
import net.arvin.view.NormalDialog.MyDialogListener;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;

public class UrlDialog extends Dialog implements OnClickListener {

	public Context mContext;
	private LinearLayout btn_ok;
	public TextView messages;

	private MyDialogListener mListener;

	public UrlDialog(Context context, int theme, MyDialogListener listener) {
		super(context, theme);
		this.mContext = context;
		setContentView(R.layout.dialog_url);
		DisplayMetrics metrics = context.getResources().getDisplayMetrics();
		int screenWidth = (int) (metrics.widthPixels * 0.90);
		getWindow().setLayout(screenWidth, LayoutParams.WRAP_CONTENT);
		this.mListener = listener;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initView();
	}

	private void initView() {
		btn_ok = (LinearLayout) getWindow().findViewById(
				R.id.dialog_btn_ok);
		btn_ok.setOnClickListener(this);
	}

	public UrlDialog setMessages(String message) {
		messages.setText(message);
		return this;
	}

	@Override
	public void onClick(View v) {
		mListener.onClick(v);
	}
}
